Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Montplaisir2014-05-02 16:44:23 -0400
committerAlexandre Montplaisir2014-05-08 18:55:47 -0400
commitddb3f6da651d8c81e384b21ee183ab59cdf3ed5c (patch)
tree34dcb49378625409f4d4348a4018af1c5a89ad60
parent9fe592ba2f0e28c7c95c579057f9ba5e3a4f5fca (diff)
downloadorg.eclipse.linuxtools-ddb3f6da651d8c81e384b21ee183ab59cdf3ed5c.tar.gz
org.eclipse.linuxtools-ddb3f6da651d8c81e384b21ee183ab59cdf3ed5c.tar.xz
org.eclipse.linuxtools-ddb3f6da651d8c81e384b21ee183ab59cdf3ed5c.zip
tmf: Make IAnalysisModule AutoCloseable
This will help ensure that we always close()/dispose() analysis modules when we are done using them. This exposed many places in the tests where unclosed modules could be leaking resources. Change-Id: I32b9168d27460bd5daca61edebc38746a919ee4d Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im> Reviewed-on: https://git.eclipse.org/r/25895 Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net> Tested-by: Hudson CI
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/GenerateTestValues.java25
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/PartialStateSystemTest.java7
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemFullHistoryTest.java60
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemInMemoryTest.java13
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.ust.core.tests/src/org/eclipse/linuxtools/lttng2/ust/core/tests/trace/callstack/AbstractProviderTest.java41
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisModuleTest.java84
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/IAnalysisModule.java9
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAbstractAnalysisModule.java5
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ctf.core.tests/src/org/eclipse/linuxtools/tmf/ctf/core/tests/CtfTmfLostEventStatisticsTest.java27
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ctf.core.tests/src/org/eclipse/linuxtools/tmf/ctf/core/tests/statistics/TmfStateStatisticsTest.java25
10 files changed, 172 insertions, 124 deletions
diff --git a/lttng/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/GenerateTestValues.java b/lttng/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/GenerateTestValues.java
index 3d3a573b30..95e5324887 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/GenerateTestValues.java
+++ b/lttng/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/GenerateTestValues.java
@@ -58,18 +58,19 @@ public class GenerateTestValues {
/* Prepare the files */
File logFile = File.createTempFile("TestValues", ".java");
try (final CtfTmfTrace trace = testTrace.getTrace();
- PrintWriter writer = new PrintWriter(new FileWriter(logFile), true);) {
- /* Build and query the state system */
- TmfStateSystemAnalysisModule module = new TmfStateSystemAnalysisModule() {
- @Override
- protected ITmfStateProvider createStateProvider() {
- return new LttngKernelStateProvider(trace);
- }
- @Override
- protected String getSsFileName() {
- return "test-values";
- }
- };
+ PrintWriter writer = new PrintWriter(new FileWriter(logFile), true);
+ /* Build and query the state system */
+ TmfStateSystemAnalysisModule module = new TmfStateSystemAnalysisModule() {
+ @Override
+ protected ITmfStateProvider createStateProvider() {
+ return new LttngKernelStateProvider(trace);
+ }
+
+ @Override
+ protected String getSsFileName() {
+ return "test-values";
+ }
+ };) {
module.setTrace(trace);
module.setId("test-values");
module.schedule();
diff --git a/lttng/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/PartialStateSystemTest.java b/lttng/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/PartialStateSystemTest.java
index c610cc3e96..c62063adb8 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/PartialStateSystemTest.java
+++ b/lttng/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/PartialStateSystemTest.java
@@ -38,9 +38,11 @@ import org.junit.Test;
*/
public class PartialStateSystemTest extends StateSystemTest {
- private static File stateFile;
private static final String TEST_FILE_NAME = "test-partial";
+ private static File stateFile;
+ private static TestLttngKernelAnalysisModule module;
+
/**
* Initialization
@@ -53,7 +55,7 @@ public class PartialStateSystemTest extends StateSystemTest {
stateFile.delete();
}
- TestLttngKernelAnalysisModule module = new TestLttngKernelAnalysisModule(TEST_FILE_NAME);
+ module = new TestLttngKernelAnalysisModule(TEST_FILE_NAME);
try {
module.setTrace(testTrace.getTrace());
} catch (TmfAnalysisException e) {
@@ -71,6 +73,7 @@ public class PartialStateSystemTest extends StateSystemTest {
*/
@AfterClass
public static void tearDownClass() {
+ module.close();
stateFile.delete();
}
diff --git a/lttng/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemFullHistoryTest.java b/lttng/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemFullHistoryTest.java
index 2fc1c71a6b..17863e7c74 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemFullHistoryTest.java
+++ b/lttng/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemFullHistoryTest.java
@@ -41,11 +41,13 @@ import org.junit.Test;
*/
public class StateSystemFullHistoryTest extends StateSystemTest {
+ private static final String TEST_FILE_NAME = "test.ht";
+ private static final String BENCHMARK_FILE_NAME = "test.benchmark.ht";
+
private static File stateFile;
private static File stateFileBenchmark;
+ private static TestLttngKernelAnalysisModule module;
- private static final String TEST_FILE_NAME = "test.ht";
- private static final String BENCHMARK_FILE_NAME = "test.benchmark.ht";
/**
* Initialize the test cases (build the history file once for all tests).
@@ -56,7 +58,7 @@ public class StateSystemFullHistoryTest extends StateSystemTest {
stateFile = createStateFile(TEST_FILE_NAME);
stateFileBenchmark = createStateFile(BENCHMARK_FILE_NAME);
- TestLttngKernelAnalysisModule module = new TestLttngKernelAnalysisModule(TEST_FILE_NAME);
+ module = new TestLttngKernelAnalysisModule(TEST_FILE_NAME);
try {
module.setTrace(testTrace.getTrace());
} catch (TmfAnalysisException e) {
@@ -74,6 +76,7 @@ public class StateSystemFullHistoryTest extends StateSystemTest {
*/
@AfterClass
public static void tearDownClass() {
+ module.close();
stateFile.delete();
stateFileBenchmark.delete();
}
@@ -88,19 +91,21 @@ public class StateSystemFullHistoryTest extends StateSystemTest {
*/
@Test
public void testBuild() {
- TestLttngKernelAnalysisModule module2 = new TestLttngKernelAnalysisModule(BENCHMARK_FILE_NAME);
- try {
- module2.setTrace(testTrace.getTrace());
- } catch (TmfAnalysisException e) {
- fail();
- }
- module2.schedule();
- assertTrue(module2.waitForCompletion());
- ITmfStateSystem ssb2 = module2.getStateSystem();
+ try (TestLttngKernelAnalysisModule module2 =
+ new TestLttngKernelAnalysisModule(BENCHMARK_FILE_NAME);) {
+ try {
+ module2.setTrace(testTrace.getTrace());
+ } catch (TmfAnalysisException e) {
+ fail();
+ }
+ module2.schedule();
+ assertTrue(module2.waitForCompletion());
+ ITmfStateSystem ssb2 = module2.getStateSystem();
- assertNotNull(ssb2);
- assertEquals(startTime, ssb2.getStartTime());
- assertEquals(endTime, ssb2.getCurrentEndTime());
+ assertNotNull(ssb2);
+ assertEquals(startTime, ssb2.getStartTime());
+ assertEquals(endTime, ssb2.getCurrentEndTime());
+ }
}
/**
@@ -109,19 +114,20 @@ public class StateSystemFullHistoryTest extends StateSystemTest {
@Test
public void testOpenExistingStateFile() {
/* 'newStateFile' should have already been created */
- TestLttngKernelAnalysisModule module2 = new TestLttngKernelAnalysisModule(TEST_FILE_NAME);
- try {
- module2.setTrace(testTrace.getTrace());
- } catch (TmfAnalysisException e) {
- fail();
- }
- module2.schedule();
- assertTrue(module2.waitForCompletion());
- ITmfStateSystem ssb2 = module2.getStateSystem();
+ try (TestLttngKernelAnalysisModule module2 = new TestLttngKernelAnalysisModule(TEST_FILE_NAME);) {
+ try {
+ module2.setTrace(testTrace.getTrace());
+ } catch (TmfAnalysisException e) {
+ fail();
+ }
+ module2.schedule();
+ assertTrue(module2.waitForCompletion());
+ ITmfStateSystem ssb2 = module2.getStateSystem();
- assertNotNull(ssb2);
- assertEquals(startTime, ssb2.getStartTime());
- assertEquals(endTime, ssb2.getCurrentEndTime());
+ assertNotNull(ssb2);
+ assertEquals(startTime, ssb2.getStartTime());
+ assertEquals(endTime, ssb2.getCurrentEndTime());
+ }
}
private static class TestLttngKernelAnalysisModule extends TmfStateSystemAnalysisModule {
diff --git a/lttng/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemInMemoryTest.java b/lttng/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemInMemoryTest.java
index 0c4b838520..8cb40fbaf7 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemInMemoryTest.java
+++ b/lttng/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemInMemoryTest.java
@@ -24,6 +24,7 @@ import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider;
import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemAnalysisModule;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
import org.eclipse.linuxtools.tmf.ctf.core.CtfTmfTrace;
+import org.junit.AfterClass;
import org.junit.BeforeClass;
/**
@@ -33,6 +34,8 @@ import org.junit.BeforeClass;
*/
public class StateSystemInMemoryTest extends StateSystemTest {
+ private static TestLttngKernelAnalysisModule module;
+
/**
* Initialization
*/
@@ -40,7 +43,7 @@ public class StateSystemInMemoryTest extends StateSystemTest {
public static void initialize() {
assumeTrue(testTrace.exists());
- TestLttngKernelAnalysisModule module = new TestLttngKernelAnalysisModule();
+ module = new TestLttngKernelAnalysisModule();
try {
module.setTrace(testTrace.getTrace());
} catch (TmfAnalysisException e) {
@@ -52,6 +55,14 @@ public class StateSystemInMemoryTest extends StateSystemTest {
assertNotNull(ssq);
}
+ /**
+ * Class cleanup
+ */
+ @AfterClass
+ public static void cleanupClass() {
+ module.close();
+ }
+
private static class TestLttngKernelAnalysisModule extends TmfStateSystemAnalysisModule {
/**
diff --git a/lttng/org.eclipse.linuxtools.lttng2.ust.core.tests/src/org/eclipse/linuxtools/lttng2/ust/core/tests/trace/callstack/AbstractProviderTest.java b/lttng/org.eclipse.linuxtools.lttng2.ust.core.tests/src/org/eclipse/linuxtools/lttng2/ust/core/tests/trace/callstack/AbstractProviderTest.java
index 2d78a503b2..a138bfdd98 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.ust.core.tests/src/org/eclipse/linuxtools/lttng2/ust/core/tests/trace/callstack/AbstractProviderTest.java
+++ b/lttng/org.eclipse.linuxtools.lttng2.ust.core.tests/src/org/eclipse/linuxtools/lttng2/ust/core/tests/trace/callstack/AbstractProviderTest.java
@@ -61,6 +61,8 @@ public abstract class AbstractProviderTest {
private CtfTmfTrace fTrace = null;
private ITmfStateSystem fSS = null;
+ private TestLttngCallStackModule fModule;
+
// ------------------------------------------------------------------------
// Abstract methods
@@ -98,16 +100,16 @@ public abstract class AbstractProviderTest {
assumeTrue(testTrace.exists());
fTrace = testTrace.getTrace();
- TestLttngCallStackModule module = new TestLttngCallStackModule();
+ fModule = new TestLttngCallStackModule();
try {
- module.setTrace(fTrace);
+ fModule.setTrace(fTrace);
} catch (TmfAnalysisException e) {
fail();
}
- module.schedule();
- assertTrue(module.waitForCompletion());
+ fModule.schedule();
+ assertTrue(fModule.waitForCompletion());
- fSS = module.getStateSystem();
+ fSS = fModule.getStateSystem();
assertNotNull(fSS);
}
@@ -116,6 +118,7 @@ public abstract class AbstractProviderTest {
*/
@After
public void tearDown() {
+ fModule.close();
if (fTrace != null) {
fTrace.dispose();
File suppDir = new File(TmfTraceManager.getSupplementaryFileDir(fTrace));
@@ -135,21 +138,21 @@ public abstract class AbstractProviderTest {
public void testOtherUstTrace() {
/* Initialize the trace and analysis module */
final ITmfTrace ustTrace = otherUstTrace.getTrace();
- TestLttngCallStackModule module = new TestLttngCallStackModule();
- try {
- module.setTrace(ustTrace);
- } catch (TmfAnalysisException e) {
- fail();
+ try (TestLttngCallStackModule module = new TestLttngCallStackModule();) {
+ try {
+ module.setTrace(ustTrace);
+ } catch (TmfAnalysisException e) {
+ fail();
+ }
+ module.schedule();
+ assertTrue(module.waitForCompletion());
+
+ /* Make sure the generated state system exists, but is empty */
+ ITmfStateSystem ss = module.getStateSystem();
+ assertNotNull(ss);
+ assertTrue(ss.getStartTime() >= ustTrace.getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue());
+ assertEquals(0, ss.getNbAttributes());
}
- module.schedule();
- assertTrue(module.waitForCompletion());
-
- /* Make sure the generated state system exists, but is empty */
- ITmfStateSystem ss = module.getStateSystem();
- assertNotNull(ss);
- assertTrue(ss.getStartTime() >= ustTrace.getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue());
- assertEquals(0, ss.getNbAttributes());
-
/* Dispose the trace */
ustTrace.dispose();
File suppDir = new File(TmfTraceManager.getSupplementaryFileDir(ustTrace));
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisModuleTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisModuleTest.java
index 80a151005c..e963752726 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisModuleTest.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisModuleTest.java
@@ -55,33 +55,34 @@ public class AnalysisModuleTest {
*/
@Test
public void testGettersSetters() {
- IAnalysisModule module = new TestAnalysis();
-
- module.setName(MODULE_GENERIC_NAME);
- module.setId(MODULE_GENERIC_ID);
- assertEquals(MODULE_GENERIC_ID, module.getId());
- assertEquals(MODULE_GENERIC_NAME, module.getName());
-
- module.setAutomatic(false);
- assertFalse(module.isAutomatic());
- module.setAutomatic(true);
- assertTrue(module.isAutomatic());
- module.addParameter(TestAnalysis.PARAM_TEST);
- assertNull(module.getParameter(TestAnalysis.PARAM_TEST));
- module.setParameter(TestAnalysis.PARAM_TEST, 1);
- assertEquals(1, module.getParameter(TestAnalysis.PARAM_TEST));
-
- /* Try to set and get wrong parameter */
- String wrongParam = "abc";
- Exception exception = null;
- try {
- module.setParameter(wrongParam, 1);
- } catch (RuntimeException e) {
- exception = e;
- assertEquals(NLS.bind(Messages.TmfAbstractAnalysisModule_InvalidParameter, wrongParam, module.getName()), e.getMessage());
+ try (IAnalysisModule module = new TestAnalysis();) {
+
+ module.setName(MODULE_GENERIC_NAME);
+ module.setId(MODULE_GENERIC_ID);
+ assertEquals(MODULE_GENERIC_ID, module.getId());
+ assertEquals(MODULE_GENERIC_NAME, module.getName());
+
+ module.setAutomatic(false);
+ assertFalse(module.isAutomatic());
+ module.setAutomatic(true);
+ assertTrue(module.isAutomatic());
+ module.addParameter(TestAnalysis.PARAM_TEST);
+ assertNull(module.getParameter(TestAnalysis.PARAM_TEST));
+ module.setParameter(TestAnalysis.PARAM_TEST, 1);
+ assertEquals(1, module.getParameter(TestAnalysis.PARAM_TEST));
+
+ /* Try to set and get wrong parameter */
+ String wrongParam = "abc";
+ Exception exception = null;
+ try {
+ module.setParameter(wrongParam, 1);
+ } catch (RuntimeException e) {
+ exception = e;
+ assertEquals(NLS.bind(Messages.TmfAbstractAnalysisModule_InvalidParameter, wrongParam, module.getName()), e.getMessage());
+ }
+ assertNotNull(exception);
+ assertNull(module.getParameter(wrongParam));
}
- assertNotNull(exception);
- assertNull(module.getParameter(wrongParam));
}
private static TestAnalysis setUpAnalysis() {
@@ -92,7 +93,6 @@ public class AnalysisModuleTest {
module.addParameter(TestAnalysis.PARAM_TEST);
return module;
-
}
/**
@@ -153,22 +153,22 @@ public class AnalysisModuleTest {
*/
@Test
public void testSetWrongTrace() {
- IAnalysisModule module = new TestAnalysis2();
-
- module.setName(MODULE_GENERIC_NAME);
- module.setId(MODULE_GENERIC_ID);
- assertEquals(MODULE_GENERIC_ID, module.getId());
- assertEquals(MODULE_GENERIC_NAME, module.getName());
-
- Exception exception = null;
- try {
- module.setTrace(TmfTestTrace.A_TEST_10K.getTrace());
- } catch (TmfAnalysisException e) {
- exception = e;
+ try (IAnalysisModule module = new TestAnalysis2();) {
+
+ module.setName(MODULE_GENERIC_NAME);
+ module.setId(MODULE_GENERIC_ID);
+ assertEquals(MODULE_GENERIC_ID, module.getId());
+ assertEquals(MODULE_GENERIC_NAME, module.getName());
+
+ Exception exception = null;
+ try {
+ module.setTrace(TmfTestTrace.A_TEST_10K.getTrace());
+ } catch (TmfAnalysisException e) {
+ exception = e;
+ }
+ assertNotNull(exception);
+ assertEquals(NLS.bind(Messages.TmfAbstractAnalysisModule_AnalysisCannotExecute, module.getName()), exception.getMessage());
}
- assertNotNull(exception);
- assertEquals(NLS.bind(Messages.TmfAbstractAnalysisModule_AnalysisCannotExecute, module.getName()), exception.getMessage());
-
}
/**
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/IAnalysisModule.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/IAnalysisModule.java
index 98b651114a..a2c1377b16 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/IAnalysisModule.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/IAnalysisModule.java
@@ -42,7 +42,7 @@ import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
* @author Geneviève Bastien
* @since 3.0
*/
-public interface IAnalysisModule extends ITmfComponent, IAnalysisRequirementProvider {
+public interface IAnalysisModule extends ITmfComponent, IAnalysisRequirementProvider, AutoCloseable {
// --------------------------------------------------------
// Getters and setters
@@ -239,4 +239,11 @@ public interface IAnalysisModule extends ITmfComponent, IAnalysisRequirementProv
* The of the parameter that changed
*/
void notifyParameterChanged(String name);
+
+ // -----------------------------------------------------
+ // AutoCloseable (remove the thrown exception)
+ // -----------------------------------------------------
+
+ @Override
+ void close();
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAbstractAnalysisModule.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAbstractAnalysisModule.java
index d8e4e97ee0..f0403d7c9a 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAbstractAnalysisModule.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAbstractAnalysisModule.java
@@ -241,6 +241,11 @@ public abstract class TmfAbstractAnalysisModule extends TmfComponent implements
}
@Override
+ public void close() {
+ dispose();
+ }
+
+ @Override
public void dispose() {
super.dispose();
cancel();
diff --git a/lttng/org.eclipse.linuxtools.tmf.ctf.core.tests/src/org/eclipse/linuxtools/tmf/ctf/core/tests/CtfTmfLostEventStatisticsTest.java b/lttng/org.eclipse.linuxtools.tmf.ctf.core.tests/src/org/eclipse/linuxtools/tmf/ctf/core/tests/CtfTmfLostEventStatisticsTest.java
index a4009512e1..069281492d 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ctf.core.tests/src/org/eclipse/linuxtools/tmf/ctf/core/tests/CtfTmfLostEventStatisticsTest.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ctf.core.tests/src/org/eclipse/linuxtools/tmf/ctf/core/tests/CtfTmfLostEventStatisticsTest.java
@@ -56,6 +56,10 @@ public class CtfTmfLostEventStatisticsTest {
/** The statistics back-end object for the trace with lost events */
private ITmfStatistics fStats;
+ /* The two analysis modules needed for fStats */
+ private TmfStatisticsTotalsModule fTotalsMod;
+ private TmfStatisticsEventTypesModule fEventTypesMod;
+
// ------------------------------------------------------------------------
// Maintenance
// ------------------------------------------------------------------------
@@ -76,22 +80,22 @@ public class CtfTmfLostEventStatisticsTest {
fTrace = lostEventsTrace.getTrace();
/* Prepare the two analysis-backed state systems */
- TmfStatisticsTotalsModule totalsMod = new TmfStatisticsTotalsModule();
- TmfStatisticsEventTypesModule eventTypesMod = new TmfStatisticsEventTypesModule();
+ fTotalsMod = new TmfStatisticsTotalsModule();
+ fEventTypesMod = new TmfStatisticsEventTypesModule();
try {
- totalsMod.setTrace(fTrace);
- eventTypesMod.setTrace(fTrace);
+ fTotalsMod.setTrace(fTrace);
+ fEventTypesMod.setTrace(fTrace);
} catch (TmfAnalysisException e) {
fail();
}
- totalsMod.schedule();
- eventTypesMod.schedule();
- assertTrue(totalsMod.waitForCompletion());
- assertTrue(eventTypesMod.waitForCompletion());
+ fTotalsMod.schedule();
+ fEventTypesMod.schedule();
+ assertTrue(fTotalsMod.waitForCompletion());
+ assertTrue(fEventTypesMod.waitForCompletion());
- ITmfStateSystem totalsSS = totalsMod.getStateSystem();
- ITmfStateSystem eventTypesSS = eventTypesMod.getStateSystem();
+ ITmfStateSystem totalsSS = fTotalsMod.getStateSystem();
+ ITmfStateSystem eventTypesSS = fEventTypesMod.getStateSystem();
assertNotNull(totalsSS);
assertNotNull(eventTypesSS);
@@ -103,6 +107,9 @@ public class CtfTmfLostEventStatisticsTest {
*/
@After
public void tearDown() {
+ fStats.dispose();
+ fTotalsMod.close();
+ fEventTypesMod.close();
fTrace.dispose();
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ctf.core.tests/src/org/eclipse/linuxtools/tmf/ctf/core/tests/statistics/TmfStateStatisticsTest.java b/lttng/org.eclipse.linuxtools.tmf.ctf.core.tests/src/org/eclipse/linuxtools/tmf/ctf/core/tests/statistics/TmfStateStatisticsTest.java
index 1b49bbb8da..b8a6c526df 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ctf.core.tests/src/org/eclipse/linuxtools/tmf/ctf/core/tests/statistics/TmfStateStatisticsTest.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ctf.core.tests/src/org/eclipse/linuxtools/tmf/ctf/core/tests/statistics/TmfStateStatisticsTest.java
@@ -36,6 +36,9 @@ public class TmfStateStatisticsTest extends TmfStatisticsTest {
private ITmfTrace fTrace;
+ private TmfStatisticsTotalsModule fTotalsMod;
+ private TmfStatisticsEventTypesModule fEventTypesMod;
+
/**
* Class setup
*/
@@ -52,22 +55,22 @@ public class TmfStateStatisticsTest extends TmfStatisticsTest {
fTrace = testTrace.getTrace();
/* Prepare the two analysis-backed state systems */
- TmfStatisticsTotalsModule totalsMod = new TmfStatisticsTotalsModule();
- TmfStatisticsEventTypesModule eventTypesMod = new TmfStatisticsEventTypesModule();
+ fTotalsMod = new TmfStatisticsTotalsModule();
+ fEventTypesMod = new TmfStatisticsEventTypesModule();
try {
- totalsMod.setTrace(fTrace);
- eventTypesMod.setTrace(fTrace);
+ fTotalsMod.setTrace(fTrace);
+ fEventTypesMod.setTrace(fTrace);
} catch (TmfAnalysisException e) {
fail();
}
- totalsMod.schedule();
- eventTypesMod.schedule();
- assertTrue(totalsMod.waitForCompletion());
- assertTrue(eventTypesMod.waitForCompletion());
+ fTotalsMod.schedule();
+ fEventTypesMod.schedule();
+ assertTrue(fTotalsMod.waitForCompletion());
+ assertTrue(fEventTypesMod.waitForCompletion());
- ITmfStateSystem totalsSS = totalsMod.getStateSystem();
- ITmfStateSystem eventTypesSS = eventTypesMod.getStateSystem();
+ ITmfStateSystem totalsSS = fTotalsMod.getStateSystem();
+ ITmfStateSystem eventTypesSS = fEventTypesMod.getStateSystem();
assertNotNull(totalsSS);
assertNotNull(eventTypesSS);
@@ -79,6 +82,8 @@ public class TmfStateStatisticsTest extends TmfStatisticsTest {
*/
@After
public void tearDown() {
+ fTotalsMod.close();
+ fEventTypesMod.close();
fTrace.dispose();
}
}

Back to the top