tmf: Fix remaining TmfSignalManager leaking listeners
authorPatrick Tasse <patrick.tasse@gmail.com>
Thu, 15 Dec 2016 18:00:15 +0000 (13:00 -0500)
committerPatrick Tasse <patrick.tasse@gmail.com>
Mon, 19 Dec 2016 21:23:48 +0000 (16:23 -0500)
Change-Id: Ie85771e159ae0ff7bfc23047c5d76915dc3999f3
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/87263
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
ctf/org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ctf/ui/swtbot/tests/AbstractImportAndReadSmokeTest.java
lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/analysis/kernel/LttngKernelAnalysisTest.java
lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/event/matchandsync/ExperimentSyncTest.java
lttng/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/analysis/debuginfo/UstDebugInfoAnalysisModuleTest.java
lttng/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/callstack/LTTngUstCallStackAnalysisRequirementTest.java
lttng/org.eclipse.tracecompass.lttng2.ust.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/ust/ui/swtbot/tests/CallStackViewTest.java
lttng/org.eclipse.tracecompass.lttng2.ust.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/ust/ui/swtbot/tests/MemoryUsageViewTest.java
tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/project/model/TraceAndExperimentTypeTest.java
tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/views/uml2sd/loader/Uml2SDTestFacility.java

index 22b52fd0251da37de2c047b927a472360e5f4aba..17d9daa3f2847df66e09afec2a3aeabd9198fd75 100644 (file)
@@ -74,7 +74,7 @@ public abstract class AbstractImportAndReadSmokeTest {
     /** Trace type name for generic CTF traces */
     protected static final String TRACE_TYPE_NAME = "Generic CTF Trace";
     /** A Generic CTF Trace */
-    protected static final @NonNull CtfTestTrace fTrace = CtfTestTrace.SYNC_DEST;
+    protected static final @NonNull CtfTmfTrace fTrace = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.SYNC_DEST);
     /** SWT BOT workbench reference */
     protected static SWTWorkbenchBot fBot;
     /** Wizard to use */
@@ -106,6 +106,7 @@ public abstract class AbstractImportAndReadSmokeTest {
      */
     @AfterClass
     public static void terminate() {
+        CtfTmfTestTraceUtils.dispose(CtfTestTrace.SYNC_DEST);
         fLogger.removeAllAppenders();
     }
 
@@ -280,9 +281,8 @@ public abstract class AbstractImportAndReadSmokeTest {
      * @return the event at given rank
      */
     protected CtfTmfEvent getEvent(int rank) {
-        CtfTmfTrace trace = CtfTmfTestTraceUtils.getTrace(fTrace);
-        ITmfContext ctx = trace.seekEvent(rank);
-        CtfTmfEvent ret = trace.getNext(ctx);
+        ITmfContext ctx = fTrace.seekEvent(rank);
+        CtfTmfEvent ret = fTrace.getNext(ctx);
         ctx.dispose();
         return ret;
     }
index 6ed0d35835ab95dea7dff37eb54578ea2f7de007..ef157c25c48caa23941ffb4e7ffce31be09b1833 100644 (file)
@@ -22,13 +22,12 @@ import java.util.List;
 
 import org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule;
 import org.eclipse.tracecompass.lttng2.kernel.core.trace.LttngKernelTrace;
+import org.eclipse.tracecompass.lttng2.lttng.kernel.core.tests.shared.LttngKernelTestTraceUtils;
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
 import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
-import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
 import org.eclipse.tracecompass.tmf.core.tests.shared.TmfTestHelper;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
-import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent;
 import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils;
 import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
 import org.junit.After;
@@ -51,16 +50,7 @@ public class LttngKernelAnalysisTest {
     @Before
     public void setUp() {
         fKernelAnalysisModule = new KernelAnalysisModule();
-        // Rework the utils to allow creating a sub-type directly.
-        String path = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.KERNEL).getPath();
-
-        fTrace = new LttngKernelTrace();
-        try {
-            fTrace.initTrace(null, path, CtfTmfEvent.class);
-        } catch (TmfTraceException e) {
-            /* Should not happen if tracesExist() passed */
-            throw new RuntimeException(e);
-        }
+        fTrace = LttngKernelTestTraceUtils.getTrace(CtfTestTrace.KERNEL);
     }
 
     /**
@@ -68,7 +58,7 @@ public class LttngKernelAnalysisTest {
      */
     @After
     public void tearDown() {
-        fTrace.dispose();
+        LttngKernelTestTraceUtils.dispose(CtfTestTrace.KERNEL);
         fKernelAnalysisModule.dispose();
         fTrace = null;
         fKernelAnalysisModule = null;
@@ -116,7 +106,7 @@ public class LttngKernelAnalysisTest {
          * in the kernel analysis so it will return true.
          */
         assertTrue(fKernelAnalysisModule.canExecute(trace));
-        trace.dispose();
+        CtfTmfTestTraceUtils.dispose(CtfTestTrace.CYG_PROFILE);
     }
 
 }
index 1cd50c84c232b7097bb4e836733dc9c976e45797..c91b7a505df48dccadb96a128e8ee30c17b69ab2 100644 (file)
@@ -82,8 +82,7 @@ public class ExperimentSyncTest {
         assertEquals(syncAlgo.getTimestampTransform(trace1.getHostId()), trace1.getTimestampTransform());
         assertEquals(syncAlgo.getTimestampTransform(trace2.getHostId()), trace2.getTimestampTransform());
 
-        trace1.dispose();
-        trace2.dispose();
+        experiment.dispose();
     }
 
     /**
@@ -113,8 +112,6 @@ public class ExperimentSyncTest {
         assertEquals("TmfTimestampTransformLinearFast [ slope = 0.9999996313017589597204633828681240, offset = 498490309972.0038068817738527724192 ]", tt2.toString());
         assertEquals("TmfTimestampTransformLinearFast [ slope = 1.000000119014882262265342419815932, offset = -166652893534.6189900382736187431134 ]", tt3.toString());
 
-        trace1.dispose();
-        trace2.dispose();
-        trace3.dispose();
+        experiment.dispose();
     }
 }
index 38ae3740031963ddc678bfd0631823bacbe248f5..5861fb5eb9645b50644fe1e8f0d18e2a724b6015 100644 (file)
@@ -25,6 +25,7 @@ import org.eclipse.tracecompass.lttng2.ust.core.analysis.debuginfo.UstDebugInfoA
 import org.eclipse.tracecompass.lttng2.ust.core.analysis.debuginfo.UstDebugInfoBinaryAspect;
 import org.eclipse.tracecompass.lttng2.ust.core.analysis.debuginfo.UstDebugInfoBinaryFile;
 import org.eclipse.tracecompass.lttng2.ust.core.analysis.debuginfo.UstDebugInfoLoadedBinaryFile;
+import org.eclipse.tracecompass.lttng2.ust.core.tests.shared.LttngUstTestTraceUtils;
 import org.eclipse.tracecompass.lttng2.ust.core.trace.LttngUstEvent;
 import org.eclipse.tracecompass.lttng2.ust.core.trace.LttngUstTrace;
 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
@@ -32,14 +33,12 @@ import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
 import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAbstractAnalysisRequirement;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
-import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
 import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest.ExecutionType;
 import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest;
 import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
 import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
 import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
-import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent;
-import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -60,7 +59,6 @@ public class UstDebugInfoAnalysisModuleTest {
     private static final @NonNull CtfTestTrace SYNTH_BUILDID_DEBUGLINK_TRACE = CtfTestTrace.DEBUG_INFO_SYNTH_BUILDID_DEBUGLINK;
     private static final @NonNull CtfTestTrace INVALID_TRACE = CtfTestTrace.CYG_PROFILE;
 
-    private LttngUstTrace fTrace;
     private UstDebugInfoAnalysisModule fModule;
 
     /**
@@ -76,26 +74,10 @@ public class UstDebugInfoAnalysisModuleTest {
      */
     @After
     public void tearDown() {
-        if (fTrace != null) {
-            fTrace.dispose();
-            fTrace = null;
-        }
-
         fModule.dispose();
         fModule = null;
     }
 
-    private @NonNull LttngUstTrace setupTrace(@NonNull CtfTestTrace testTrace) {
-        LttngUstTrace trace = new LttngUstTrace();
-        try {
-            trace.initTrace(null, CtfTmfTestTraceUtils.getTrace(testTrace).getPath(), CtfTmfEvent.class);
-        } catch (TmfTraceException e) {
-            fail(e.getMessage());
-        }
-        fTrace = trace;
-        return trace;
-    }
-
     /**
      * Test for {@link UstDebugInfoAnalysisModule#getAnalysisRequirements()}
      */
@@ -111,8 +93,9 @@ public class UstDebugInfoAnalysisModuleTest {
      */
     @Test
     public void testCanExecute() {
-        LttngUstTrace trace = setupTrace(REAL_TEST_TRACE);
+        LttngUstTrace trace = LttngUstTestTraceUtils.getTrace(REAL_TEST_TRACE);
         assertTrue(fModule.canExecute(trace));
+        LttngUstTestTraceUtils.dispose(REAL_TEST_TRACE);
     }
 
     /**
@@ -121,14 +104,15 @@ public class UstDebugInfoAnalysisModuleTest {
      */
     @Test
     public void testCannotExcecute() {
-        LttngUstTrace invalidTrace = setupTrace(INVALID_TRACE);
+        LttngUstTrace invalidTrace = LttngUstTestTraceUtils.getTrace(INVALID_TRACE);
         assertFalse(fModule.canExecute(invalidTrace));
+        LttngUstTestTraceUtils.dispose(INVALID_TRACE);
     }
 
-    private void executeModule() {
-        assertNotNull(fTrace);
+    private void executeModule(ITmfTrace trace) {
+        assertNotNull(trace);
         try {
-            fModule.setTrace(fTrace);
+            fModule.setTrace(trace);
         } catch (TmfAnalysisException e) {
             fail();
         }
@@ -141,10 +125,11 @@ public class UstDebugInfoAnalysisModuleTest {
      */
     @Test
     public void testExecution() {
-        setupTrace(REAL_TEST_TRACE);
-        executeModule();
+        LttngUstTrace trace = LttngUstTestTraceUtils.getTrace(REAL_TEST_TRACE);
+        executeModule(trace);
         ITmfStateSystem ss = fModule.getStateSystem();
         assertNotNull(ss);
+        LttngUstTestTraceUtils.dispose(REAL_TEST_TRACE);
     }
 
     /**
@@ -156,7 +141,7 @@ public class UstDebugInfoAnalysisModuleTest {
      */
     @Test
     public void testBinaryCallsites() {
-        LttngUstTrace trace = setupTrace(REAL_TEST_TRACE);
+        LttngUstTrace trace = LttngUstTestTraceUtils.getTrace(REAL_TEST_TRACE);
 
         /*
          * Fake a "trace opened" signal, so that the relevant analyses are
@@ -191,6 +176,8 @@ public class UstDebugInfoAnalysisModuleTest {
         String actual = checkNotNull(aspect.resolve(events.get(0))).toString();
         String expected = "/home/simark/src/babeltrace/tests/debug-info-data/libhello_so+0x14d4";
         assertEquals(expected, actual);
+
+        LttngUstTestTraceUtils.dispose(REAL_TEST_TRACE);
     }
 
     /**
@@ -202,8 +189,8 @@ public class UstDebugInfoAnalysisModuleTest {
 
         int vpid = 1337;
 
-        setupTrace(SYNTH_EXEC_TRACE);
-        executeModule();
+        LttngUstTrace trace = LttngUstTestTraceUtils.getTrace(SYNTH_EXEC_TRACE);
+        executeModule(trace);
 
         expected = new UstDebugInfoLoadedBinaryFile(0x400000, "/tmp/foo", null, null, false);
         matchingFile = fModule.getMatchingFile(4000000, vpid, 0x400100);
@@ -216,6 +203,8 @@ public class UstDebugInfoAnalysisModuleTest {
         expected = new UstDebugInfoLoadedBinaryFile(0x500000, "/tmp/bar", null, null, false);
         matchingFile = fModule.getMatchingFile(9000000, vpid, 0x500100);
         assertEquals(expected, matchingFile);
+
+        LttngUstTestTraceUtils.dispose(SYNTH_EXEC_TRACE);
     }
 
     /**
@@ -228,8 +217,8 @@ public class UstDebugInfoAnalysisModuleTest {
         int vpid1 = 1337;
         int vpid2 = 2001;
 
-        setupTrace(SYNTH_TWO_PROCESSES_TRACE);
-        executeModule();
+        LttngUstTrace trace = LttngUstTestTraceUtils.getTrace(SYNTH_TWO_PROCESSES_TRACE);
+        executeModule(trace);
 
         expected = new UstDebugInfoLoadedBinaryFile(0x400000, "/tmp/foo", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "/tmp/debuglink1", false);
         matchingFile = fModule.getMatchingFile(11000000, vpid1, 0x400100);
@@ -238,6 +227,8 @@ public class UstDebugInfoAnalysisModuleTest {
         expected = new UstDebugInfoLoadedBinaryFile(0x400000, "/tmp/bar", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "/tmp/debuglink2", false);
         matchingFile = fModule.getMatchingFile(12000000, vpid2, 0x400100);
         assertEquals(expected, matchingFile);
+
+        LttngUstTestTraceUtils.dispose(SYNTH_TWO_PROCESSES_TRACE);
     }
 
 
@@ -248,8 +239,8 @@ public class UstDebugInfoAnalysisModuleTest {
     public void testBuildIDDebugLink() {
         UstDebugInfoLoadedBinaryFile matchingFile, expected;
 
-        setupTrace(SYNTH_BUILDID_DEBUGLINK_TRACE);
-        executeModule();
+        LttngUstTrace trace = LttngUstTestTraceUtils.getTrace(SYNTH_BUILDID_DEBUGLINK_TRACE);
+        executeModule(trace);
 
         expected = new UstDebugInfoLoadedBinaryFile(0x400000, "/tmp/foo_nn", null, null, false);
         matchingFile = fModule.getMatchingFile(17000000, 1337, 0x400100);
@@ -266,6 +257,8 @@ public class UstDebugInfoAnalysisModuleTest {
         expected = new UstDebugInfoLoadedBinaryFile(0x400000, "/tmp/foo_yy", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "/tmp/debug_link2", false);
         matchingFile = fModule.getMatchingFile(20000000, 1340, 0x400100);
         assertEquals(expected, matchingFile);
+
+        LttngUstTestTraceUtils.dispose(SYNTH_BUILDID_DEBUGLINK_TRACE);
     }
 
     /**
@@ -273,8 +266,8 @@ public class UstDebugInfoAnalysisModuleTest {
      */
     @Test
     public void testGetAllBinaries() {
-        setupTrace(REAL_TEST_TRACE);
-        executeModule();
+        LttngUstTrace trace = LttngUstTestTraceUtils.getTrace(REAL_TEST_TRACE);
+        executeModule(trace);
 
         List<UstDebugInfoBinaryFile> actualBinaries = Lists.newArrayList(fModule.getAllBinaries());
         List<UstDebugInfoBinaryFile> expectedBinaries = Lists.newArrayList(
@@ -316,6 +309,8 @@ public class UstDebugInfoAnalysisModuleTest {
         }
 
         assertEquals(actualBinaries, expectedBinaries);
+
+        LttngUstTestTraceUtils.dispose(REAL_TEST_TRACE);
     }
 
 }
index edd870d8982653f1a9391a52c91c875829c47c02..7c2467e5a10025194b47d20cc2b173da37f30e41 100644 (file)
@@ -19,6 +19,7 @@ import org.eclipse.tracecompass.internal.lttng2.ust.core.callstack.LttngUstCallS
 import org.eclipse.tracecompass.lttng2.ust.core.trace.LttngUstTrace;
 import org.eclipse.tracecompass.lttng2.ust.core.trace.layout.ILttngUstEventLayout;
 import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEventType;
+import org.junit.AfterClass;
 import org.junit.Test;
 
 import com.google.common.collect.ImmutableSet;
@@ -109,6 +110,16 @@ public class LTTngUstCallStackAnalysisRequirementTest {
 
     }
 
+    /**
+     * Clean up
+     */
+    @AfterClass
+    public static void cleanup() {
+        for (TestData testData: TestData.values()) {
+            testData.getTrace().dispose();
+        }
+    }
+
     /**
      * Test Call Stack Analysis requirements
      */
index 5b9129d70d0c361745122ccede888f6aa04b8bb5..3d9be8e5e3110438cf92a345d91b4d11907a4e28 100644 (file)
@@ -182,6 +182,7 @@ public class CallStackViewTest {
         assertNotNull(treeItem);
         final CtfTestTrace cygProfile = CtfTestTrace.CYG_PROFILE;
         final File file = new File(CtfTmfTestTraceUtils.getTrace(cygProfile).getPath());
+        CtfTmfTestTraceUtils.dispose(cygProfile);
         SWTBotUtils.openTrace(PROJECT_NAME, file.getAbsolutePath(), UST_ID);
         SWTBotUtils.openView(CallStackView.ID);
         WaitUtils.waitForJobs();
index fcd1320cdb1cc19188a76ea3d07e1124c994a9aa..ed10d508e3027cee9c05a2188b90377b40d061ac 100644 (file)
@@ -87,6 +87,7 @@ public class MemoryUsageViewTest {
         assertNotNull(treeItem);
         final CtfTestTrace cygProfile = CtfTestTrace.MEMORY_ANALYSIS;
         final File file = new File(CtfTmfTestTraceUtils.getTrace(cygProfile).getPath());
+        CtfTmfTestTraceUtils.dispose(cygProfile);
         SWTBotUtils.openTrace(PROJECT_NAME, file.getAbsolutePath(), UST_ID);
         SWTBotUtils.openView(MemoryUsageView.ID);
         WaitUtils.waitForJobs();
index 3e168c2e1e2ddb8b549d63a9183d85dc2bfa8d7e..408eaa4882856c871fc1dfbfc173320c88d037c0 100644 (file)
@@ -87,6 +87,7 @@ public class TraceAndExperimentTypeTest {
         TmfExperiment experiment = experimentElement.instantiateTrace();
         assertNotNull(experiment);
         assertEquals(TmfTraceType.DEFAULT_EXPERIMENT_TYPE, experimentElement.getTraceType());
+        experiment.dispose();
     }
 
     /**
index 1ec91b2a7b00e217972c3a9684c43bad4b3e1edb..9f740c6abeb6fc7d90eaf5146929a3afae35b957 100644 (file)
@@ -148,6 +148,9 @@ public class Uml2SDTestFacility {
             delay(200);
             fIsInitialized = false;
         }
+        if (fTrace != null) {
+            fTrace.dispose();
+        }
     }
 
     /**
@@ -333,12 +336,11 @@ public class Uml2SDTestFacility {
      * @param wait true to wait for indexing to finish else false
      */
     public void selectExperiment(final boolean wait) {
-        fParser = new TmfUml2SDTestTrace();
-        fTrace = setupTrace(fParser);
-        fParser.setTrace(fTrace);
+        TmfUml2SDTestTrace parser = new TmfUml2SDTestTrace();
+        ITmfTrace trace = setupTrace(parser);
+        parser.setTrace(trace);
 
-        final ITmfTrace traces[] = new ITmfTrace[1];
-        traces[0] = fTrace;
+        final ITmfTrace traces[] = new ITmfTrace[] { trace };
         fExperiment = new TmfExperiment(ITmfEvent.class, "TestExperiment",
                 traces, TmfExperiment.DEFAULT_INDEX_PAGE_SIZE, null) {
             @Override
@@ -346,8 +348,8 @@ public class Uml2SDTestFacility {
                 return new TmfCheckpointIndexer(this, interval);
             }
         };
-        fTrace.broadcast(new TmfTraceOpenedSignal(this, fExperiment, null));
-        fTrace.broadcast(new TmfTraceSelectedSignal(this, fExperiment));
+        trace.broadcast(new TmfTraceOpenedSignal(this, fExperiment, null));
+        trace.broadcast(new TmfTraceSelectedSignal(this, fExperiment));
         if (wait) {
             while (fExperiment.getNbEvents() == 0) {
                 delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
@@ -361,12 +363,11 @@ public class Uml2SDTestFacility {
      * Disposes the experiment.
      */
     public void disposeExperiment() {
-        ITmfTrace trace = fTrace;
         TmfExperiment experiment = fExperiment;
-        if (trace == null || experiment == null) {
+        if (experiment == null) {
             throw new IllegalStateException();
         }
-        trace.broadcast(new TmfTraceClosedSignal(this, experiment));
+        experiment.broadcast(new TmfTraceClosedSignal(this, experiment));
         experiment.dispose();
         delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
     }
This page took 0.034323 seconds and 5 git commands to generate.